package com.bjfu.controller;

import com.bjfu.dto.*;
import com.bjfu.mapper.UserMapper;
import com.bjfu.service.SuperManagerService;
import com.bjfu.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/SuperAdmin")
public class SuperManagerController {
    @Autowired
    private SuperManagerService superManagerService;
    //创建管理员
    @PostMapping("/createTeamAdmin")
    public Result createTeamAdmin(@RequestBody AdminRequest adminRequest) {
        //前端调试
        System.out.println("username: " + adminRequest.getUsername());
        System.out.println("password: " + adminRequest.getPassword());
        return superManagerService.createTeamAdmin(adminRequest.getUsername(), adminRequest.getPassword());
    }


    // 删除管理员信息
    @DeleteMapping("/deleteTeamAdmin")
    public Result deleteTeamAdmin(@RequestBody DeleteAdminRequest deleteAdminRequest) {
        System.out.println("userid："+deleteAdminRequest.getUser_id());
        return superManagerService.deleteTeamAdmin(deleteAdminRequest.getUser_id());
    }
    // 根据ID查询管理员信息
    @GetMapping("/selectInfo")
    public Result getTeamAdminInfo(@RequestParam Long user_id) {
        System.out.println("userid："+user_id);
        return superManagerService.getTeamAdminInfo(user_id);
    }

    // 更新管理员信息
    @PutMapping("/updateInfo")
    public Result updateAdminInfo(@RequestBody UpdateAdminInfoRequest updateAdminInfoRequest) {
        // 直接将 UpdateAdminInfoRequest 传递给服务层
        return superManagerService.updateAdminInfo(updateAdminInfoRequest);
    }


    // 审核科研成果
    //pass_status是否通过，若通过则该记录的status字段由0未激活（待审核）变成1（审核通过）激活，否则变为2（审核失败）
    @PutMapping("/judgeAchivement")
    public Result judgeAchievement(@RequestBody JudgeRequest judgeAchievementRequest) {
        return superManagerService.judgeAchievement(judgeAchievementRequest);
    }

    //审核文章
    @PutMapping("/judgeArticle")
    public Result judgeArticle(@RequestBody JudgeRequest judgeArticleRequest) {
        return superManagerService.judgeArticle(judgeArticleRequest);
    }


    // 管理用户管理员权限
    @PutMapping("/rightsManagement")
    public Result rightsManagement(@RequestBody RightsManagementRequest rightsManagementRequest) {
        return superManagerService.manageRights(rightsManagementRequest);
    }

    // 查询所有团队管理员（ID和姓名）
    @GetMapping("/selectList")
    public Result getAllTeamAdmins() {
        return superManagerService.getAllTeamAdmins();
    }

    // 查看所有待审核的科研成果
    @GetMapping("/ShowAchievementNotJudge")
    public Result showAchievementNotJudge() {
        return superManagerService.showAchievementNotJudge();
    }
    // 查看所有待审核的文章
    @GetMapping("/ShowArticleNotJudge")
    public Result showArticleNotJudge() {
        return superManagerService.showArticleNotJudge();
    }
    //修改管理员密码
    @PutMapping("/updateAdminPassword")
    public Result updatePassword(@RequestBody UpdatePasswordDTO updatePasswordDTO){return superManagerService.updatePassword(updatePasswordDTO);}
    //禁用账号
    @PutMapping("/ForbiddenAdmin")
    public Result forbiddenAdmin(@RequestParam Long user_id){
        return superManagerService.forbiddenAdmin(user_id);
    }

}
